home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
T-TPUG Old Monthly Disks
/
(c)t9.d64
/
stock.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-04
|
10KB
|
291 lines
1 REM BY MIKE FLAVEL
2 REM REVISED FROM APPLE VERSION
10 C=0:D=0:A=0:ASSETS=0:B=0:BEGINC=10000:BUY=0:WAS=0:BROKER=0
20 CASH=10000:CHANGE=0:DAY=0:FEES=0:FLAG=0:INCOME=0:KEY=0:LAST=0
30 MARKET=-1:MOTH=0:PRICE=0:SELL=0:SHARES=0:QUARTER=0
40 SKS=12:IME=1000:WEEK=0:YEAR=1979:AVERAGE=0:E=0:F=0:G=0:H=0
50 DIMNAME$(SKS),DAY$(5),MOTH$(12),TABLE(SKS,5)
60 DISK$="":A$="":CHANGE$="":CHECK$="":IN$=""
70 NAME$(1)="ALCOA ALUMINUM":NAME$(2)="COMMODORE":NAME$(3)="CBS INDUSTRIES"
80 NAME$(4)="EXXON OIL":NAME$(5)="GENERAL MOTORS":NAME$(6)="HONEYWELL CORP."
90 NAME$(7)="IBM CORPORATION":NAME$(8)="INTEL CORP.":NAME$(9)="LOCKHEED CORP."
100 NAME$(10)="MOTOROLA":NAME$(11)="STANDARD OIL":NAME$(12)="3-M CORPORATION"
110 FORA=1TOSKS:FORB=1TO4:TABLE(A,B)=0:NEXTB,A
120 PRINT"[147]********************":
121 PRINTTAB(10)"** MARKET CRASH **"
130 PRINTTAB(10)"** BY MIKE FLAVEL **":PRINTTAB(10);"********************"
140 FORA=1TOSKS:PRICE=INT(RND(1)*100+1)+20:WAS=WAS+PRICE:TABLE(A,1)=PRICE
150 CHANGE=INT(RND(1)*5)-2:TABLE(A,5)=CHANGE
160 NEXTA:WAS=INT(WAS/SKS*100)/100:AVERAGE=WAS
170 MOTH$(1)="JANUARY":MOTH$(2)="FEBRUARY":MOTH$(3)="MARCH"
180 MOTH$(4)="APRIL":MOTH$(5)="MAY":MOTH$(6)="JUNE"
190 MOTH$(7)="JULY":MOTH$(8)="AUGUST":MOTH$(9)="SEPTEMBER"
200 MOTH$(10)="OCTOBER":MOTH$(11)="NOVEMBER":MOTH$(12)="DECEMBER"
210 DAY$(1)="MONDAY":DAY$(2)="TUESDAY":DAY$(3)="WEDNESDAY":DAY$(4)="THURSDAY"
215 DAY$(5)="FRIDAY"
220 WEEK=0:DAY=0:MOTH=1:LAST=31:QUARTER=0
230 PRINT"[147]DO YOU WANT INSTRUCTIONS?":GOSUB2620:IFKEY=206THEN650
240 PRINT"[147]";TAB(10)"INSTRUCTIONS[146]"
250 PRINT" THIS IS A SIMULATION OF THE OPERATIONS OF THE STOCK MARKET.THERE ARE";
260 PRINT" 12 COMPANY STOCKS AVAILABLE FOR TRADE"
270 PRINT"PROVIDING YOU HAVE THE MONEY, THERE IS A BROKERS FEE OF 6% OR $50.00 PER";
280 PRINT"STOCK. TRANSACTIONS ARE COLLECTED AT THE END OF EACH WEEK"
290 PRINT"HERE ARE THE KEY FUNCTIONS:"
300 PRINT"(S) SELL STOCK":PRINT"(B) BUY STOCK":PRINT"(RETURN) PASS":PRINT"(E) END GAME"
310 PRINT"WHEN BUYING OR SELLING STOCK ENTER AT LEAST THE FIRST THREE INITIALS "
320 PRINT"OF THE STOCK NAME"
330 PRINT"PRESS ANY KEY TO CONTINUE"
340 GOSUB2620:IFKEY=195THEN2560
650 REM
700 REM MAIN PROGRAM
710 GOSUB830
720 GOSUB1300
730 GOSUB1750
740 GOSUB1910
750 IFKEY=194ORKEY=211THEN780
760 IFKEY=197THEN2360
770 GOTO700
780 GOSUB1970
790 IFKEY=194THENGOSUB2070
800 IFKEY=211THENGOSUB2210
810 GOSUB1910
820 GOTO750
830 REM DATA FIGURES
840 MARKET=MARKET+INT(RND(1)*3)-1:IFMARKEY>2THENMARKEY=2
850 IFMARKET<-3THENMARKET=-3
860 IFRND(1)>.92THENMARKET=-1*MARKET
870 FLAG=0:WEEK=WEEK+1:DAY=DAY+1:IFDAY<=LASTTHEN910
880 DAY=DAY-LAST:MOTH=MOTH+1:IFMOTH>12THEN2890
890 QUARTER=QUARTER+1:IFQUARTER<>3THEN910
900 QUARTER=0:GOSUB1670
910 IFWEEK<=5THEN950
920 PRINT"[147]":LAST=28:IFMOTH=4ORMOTH=6ORMOTH=9ORMOTH=11THENLAST=30
930 IFMOTH=1ORMOTH=3ORMOTH=5ORMOTH=7ORMOTH=8ORMOTH=10ORMOTH=12THENLAST=31
940 FLAG=1:WEEK=0:A$="":GOTO1200
950 GOSUB1630:IFMOTH=1ANDDAY=1THEN1060
960 IF MOTH=2ANDDAY=12THENGOTO1070
970 IFMOTH=2ANDDAY=19THENGOTO1080
980 IFMOTH=5ANDDAY=28THENGOTO1090
990 IFMOTH=7ANDDAY=4THENGOTO1100
1000 IFMOTH=9ANDDAY=3THENGOTO1110
1010 IFMOTH=10ANDDAY=8THENGOTO1120
1020 IFMOTH=11ANDDAY=12THENGOTO1130
1030 IFMOTH=11ANDDAY=22THENGOTO1140
1040 IFMOTH=12ANDDAY=25THENGOTO1150
1050 GOTO1190
1060 A$="[147]NEW YEAR'S DAY":GOTO1160
1070 A$="[147]LINCOLN'S BIRTHDAY":GOTO1160
1080 A$="[147]WASHINGTON'S BIRTHDAY":GOTO1160
1090 A$="[147]MEMORIAL DAY":GOTO1160
1100 A$="[147]INDEPENDENCE DAY":GOTO1160
1110 A$="[147]LABOR DAY":GOTO1160
1120 A$="[147]COLUMBUS DAY":GOTO1160
1130 A$="[147]VETERANS DAY":GOTO1160
1140 A$="[147]THANKSGIVING DAY":GOTO1160
1150 A$="[147]CHRISTMAS"
1160 PRINTA$:FORA=1TO1000:NEXTA
1170 PRINTTAB(9)"STOCK MARKET CLOSED...":FORA=1TO1000:NEXTA:PRINT"[147]"
1180 GOTO870
1190 GOSUB1420:IFFLAG=0THENRETURN
1200 PRINTTAB(3)"WEEKEND":PRINTTAB(9)"STOCK MARKET CLOSED..."
1210 PRINT:PRINT:GOSUB1470:DAY=DAY+1:PRINT"[147]":GOTO870
1220 REM
1230 IFCASH>=0ANDWEEK>1THEN1260
1240 IFLEN(A$)>1ANDWEEK=2ANDCASH<0THEN1260
1250 IFCASH<0ANDWEEK<>1THEN2720
1260 FLAG=0:FORB=1TOSKS:IFTABLE(B,1)>0THENFLAG=B
1270 NEXTB:IFFLAG=0THEN2850
1280 FLAG=0:IFCASH<=0ANDASSETS<=0THEN2780
1290 RETURN
1300 REM MARKET FIGURES
1310 ASSETS=0:FORA=1TOSKS:IFTABLE(A,1)<=0THEN1400
1320 CHANGE=TABLE(A,5)+INT(RND(1)*3)-1:IFRND(1)>.85THEN1360
1330 IFCHANGE>2THENCHANGE=2
1340 IFCHANGE<-2THENCHANGE=-2
1350 GOTO1370
1360 CHANGE=TABLE(A,5)+INT(RND(1)*5)-2
1370 IFRND(1)>.9THENCHANGE=-1*CHANGE
1380 TABLE(A,5)=CHANGE:CHANGE=CHANGE+MARKET:TABLE(A,1)=TABLE(A,1)+CHANGE
1385 IFTABLE(A,1)<=0THEN1410
1390 TABLE(A,2)=CHANGE:TABLE(A,4)=TABLE(A,3)*TABLE(A,1)
1400 ASSETS=ASSETS+TABLE(A,4):NEXTA:GOSUB1220:RETURN
1410 FORB=1TO5:TABLE(A,B)=0:NEXTB:GOTO1400
1420 REM FIRST OR WEEK
1430 IFWEEK<>1ANDNOT(WEEK=2ANDLEN(A$)>1)THENRETURN
1440 BEGINC=0:ASSETS=0:FORB=1TOSKS:IFTABLE(B,1)<=0THEN1460
1450 ASSETS=ASSETS+TABLE(B,4)
1460 NEXTB:BEGINC=CASH+ASSETS:GOSUB1220:RETURN
1470 REM WEEKEND DATA
1480 INCOME=0:PRINT"[147]":FORA=1TOSKS
1490 INCOME=INCOME+(TABLE(A,1)*TABLE(A,3))
1500 NEXTA:PRINTTAB(3)"TOTAL INCOME FOR THE WEEK: ":PRINT
1510 PRINTTAB(5)"CASH AT WEEKEND:";TAB(27)"$";CASH:PRINTTAB(5)"CURRENT PAPER WORTH:";
1515 PRINTTAB(27);"$";INCOME
1520 PRINTTAB(27);"---------":PRINTTAB(5);"TOTAL:";TAB(27);"$";CASH+INCOME:PRINT
1530 PRINTTAB(5);"TOTAL ASSETS + CASH":PRINTTAB(5);"AT BEGINNING OF WEEK:";TAB(27)"$";
1535 PRINTBEGINC:PRINTTAB(27)"---------"
1540 PRINTTAB(5)"GROSS WEEK'S INCOME:";TAB(27);"$";(CASH+INCOME)-BEGINC:PRINTTAB(5);
1545 PRINT"LESS BROKER'S FEES";TAB(27);"$";FEES
1550 PRINT:PRINT:PRINTTAB(5);"NET WEEK'S INCOME:";TAB(27);"$";((CASH+INCOME)-BEGINC)-FEES
1555 PRINT:CASH=CASH-FEES:IFCASH>=0THEN1570
1560 PRINT"YOU HAVE UNTIL MONDAY TO BREAK":PRINT"EVEN, OR ELSE!!! (CASH: $";CASH;")"
1570 BEGINC=CASH+INCOME:FEES=0
1580 PRINT"PRESS ANY KEY TO CONTINUE...":GOSUB2620:RETURN
1590 REM ASSET PRINTOUT
1600 ASSETS=0:FORB=1TOSKS:TABLE(B,4)=TABLE(B,1)*TABLE(B,3)
1605 ASSETS=ASSETS+TABLE(B,4):NEXTB
1610 PRINT"CASH: $";CASH;TAB(23);"ASSETS: $";ASSETS
1620 PRINT:RETURN
1630 REM DATA PRINTOUT
1640 REM
1650 GOSUB4500
1651 PRINT"" TAB(3);" "
1652 PRINT"" TAB(3);"DATE:";DAY$(WEEK);",";MOTH$(MOTH);" ";DAY;",";YEAR
1660 GOSUB1220:PRINTTAB(40):LTH=FRE(0):RETURN
1670 REM DIVIDENDS PAID
1680 CASH=CASH+INT(ASSETS*.08):RETURN
1690 REM STOCK PRINTOUT
1700 CHANGE$=STR$(TABLE(A,2)):IFTABLE(A,1)<=0THEN1730
1710 IFTABLE(A,2)>0THENCHANGE$="+"+STR$(TABLE(A,2))
1720 PRINTNAME$(A);TAB(16);TABLE(A,1);TAB(21);CHANGE$;TAB(25);TABLE(A,3);
1725 PRINTTAB(30);TABLE(A,4):GOTO1740
1730 PRINT"*** ";NAME$(A);" IS BAKNRUPT...";TAB(40)
1740 RETURN
1750 REM PRINTOUT ALL
1760 WAS=AVERAGE:AVERAGE=0:
1770 PRINT"STOCK NAME";TAB(15);"CLOSE";TAB(21);"CHG";TAB(25);"OWNED";" WORTH"
1780 FORA=1TO40:PRINT"=";:NEXTA:PRINT
1790 FORA=1TOSKS:GOSUB 1690
1800 AVERAGE=AVERAGE+TABLE(A,1):NEXTA
1810 FORA=1TO40:PRINT"=";:NEXTA:PRINT
1820 AVERAGE=INT((AVERAGE/SKS)*100)/100
1830 PRINT"AVERAGE: $";AVERAGE;"/SHARE";TAB(20);
1840 CHANGE=INT((AVERAGE*100)-(WAS*100))/100
1850 IFCHANGE<>0THEN1870
1860 PRINT"(NO CHANGE)":GOTO1900
1870 IFCHANGE>0THEN1890
1880 PRINT"(DOWN ";ABS(CHANGE);")":GOTO1900
1890 PRINT"(UP";ABS(CHANGE);")"
1900 RETURN
1901 CHECK=1
1910 REMDATA INPUT
1920 REM OPTION INPUT
1930 FORX=1784+40TO2023:POKEX,32:NEXT:
1934 GOSUB1590:PRINT"(B)-BUY";TAB(20);
1935 PRINT"(S)-SELL)
1940 [153]"(E)-STOP";[163]20);"(RETURN)-PASS":[153]"WHICH FUNCTION DO YOU WANT?":[141]2620
1950 [139]KEY[178]194[176]KEY[178]211[176]KEY[178]197[176]KEY[178]141[167][142]
1960 [137]1930:[153]"WHAT????WAIT":[129]B[178]1[164]1000:[130]:[137]1930
1970 [143] STOCK INPUT
1980 [129]X[178]1784[171]40[164]2023:[151]X,32:[130]
1989 [133]"INPUT STOCK NAME: ";IN$
1990 FLAG[178]0:CHECK$[178][200](IN$,3):[129]A[178]1[164]SKS
2000 [139]CHECK$[178][200](NAME$(A),3)[167]FLAG[178]A
2010 [130]A:[139]FLAG[179][177]0[167]2050
2020 [153]IN$;"???":[129]B[178]1[164]1000:[130]
2030 [153]"THERE IS NO STOCK BY THAT NAME!!!":[129]B[178]1[164](1.5[172]1000):[130]:[142]
2040 [153]NAME$(FLAG); "IS BANKRUPT!!!":[129]B[178]1[164](2[172]1000):[130]:FLAG[178]0:[142]
2050 [139]TABLE(FLAG,1)[179][178]0[167]2040
2060 [142]
2070 [143] BUY STOCK
2080 A[178]FLAG:[139]FLAG[179][178]0[167][142]
2090 [143] GOSUB1770:
2100 [153]"HOW MANY SHARES DO YOU ":[133]"WANT TO BUY?";BUY
2101 [139]BUY[178]0[167]2200
2102 [129]X[178]1784[164]2023:[151]X,32:[130]
2110 [139]BUY[179]0[167]2190
2120 SHARES[178]TABLE(A,1)[172]BUY:[139]CASH[171]SHARES[179]0[167]2180
2130 TABLE(A,4)[178]TABLE(A,4)[170]SHARES:TABLE(A,3)[178]TABLE(A,3)[170]BUY:[141]1770
2140 BROKER[178][181](SHARES[172].06):[139]BROKER[179]50[167]2160
2150 FEES[178]FEES[170]BROKER:[137]2170
2160 FEES[178]FEES[170]50
2170 CASH[178]CASH[171]SHARES:[142]:[143]PRI-GOSUB1690
2180 [153]"NOT ENOUGH MONEY!!!";:[129]B[178]1[164](1.5[172]1000):[130]:[137]2090
2190 [153]"SAY WHAT??? TRY THAT AGAIN!!!":[129]B[178]1[164](1.5[172]TIME):[130]:[137]2090
2200 [142]:[143]GOSUB1690:RETURN
2210 [143] SELL STOCK
2220 A[178]FLAG:[139]A[179][178]0[167][142]
2230 [143]GOSUB1690
2240 [153]"HOW MANY SHARES DO YOU":[133]"WANT TO SELL ";SELL
2241 [129]X[178]1824[171]40[164]2023:[151]X,32:[130]
2245 [139]SELL[178]0[167]2330
2250 [139]SELL[177]TABLE(A,3)[167]2340
2260 [139]SELL[179]0[167]2350
2270 TABLE(A,3)[178]TABLE(A,3)[171]SELL:TABLE(A,4)[178]TABLE(A,3)[172]TABLE(A,1)
2280 CASH[178]CASH[170]TABLE(A,1)[172]SELL
2290 BROKER[178][181]((TABLE(A,1)[172]SELL)[172].0)
2300 [139]BROKER[179]50[167]2320
2310 FEES[178]FEES[170]BROKER:[137]2330
2320 FEES[178]FEES[170]50
2330 [141]4000:[141]1770:[142]
2340 [153]"??? YOU DON'T HAVE THAT MANY!!!":[129]B[178]1[164](1.5[172]1000):[130]:[137]2230
2350 [153]"SAY WHAT ??? TRY THAT AGAIN!!!":[129]B[178]1[164](1.5[172]1000):[130]:[137]2230
2360 [143] VARIABLE END
2370 [153]"LOADEND"
2440 [153]"GAME END":[153]:[153]:[153]
2450 [137]2920
2620 [143] ***KEYBOARD INPUT***
2630 [161]A$:[139]A$[178]""[167]2630
2640 KEY[178][198](A$):
2641 [139]KEY[178]66[167]KEY[178]194:[137]2646
2642 [139]KEY[178]83[167]KEY[178]211:[137]2646
2643 [139]KEY[178]69[167]KEY[178]197:[137]2646
2644 [139]KEY[178]133[167]KEY[178]141:[137]2646
2645 KEY[178]KEY[170]128
2646 [139]KEY[177]127[167]2660
2650 [137]2640
2660 [142]
2670 [143] *** B=66
2680 [143] *** S=83
2690 [143] *** E=69
2700 [143]RETURN= 13
2710 [143] END
2720 [143] BROKER
2730 [153]"YOUR BROKER HAS TAKEN LEGAL ACTION AGAINST YOUR PERSONAL ASSETS"
2735 [153]"DUE TO";
2740 [153]"YOUR DEFAULTING ON YOUR CONTRACT. YOU ARE BANKRUPT"
2770 [128]
2780 [143] PLAYER BROKE
2790 [153]"DO TO YOUR LOW IQ AND STUPIDITY YOU HAVE MANAGED TO BECOME BANKRUPT."
2800 [128]
2850 [143] MARKEY CRASH
2860 [153]"LOADTHE STOCK MARKET HAS CRASHED. ALL THE COMPANIES ARE NOW BANKRUPT!!"
2870 [139]CASH[177]1000[167]2890
2880 [153]"YOU LOST YOUR SHORTS!!!"
2890 [129]A[178]1[164](3[172]1000):[130]A:[153]"LOAD":[137]2440
2900 [143] YEAR END
2910 [141]1670:[153]"LOAD";[163]15)"YEAR END"
2920 ASSETS[178]0:[129]A[178]1[164]SKS:[139]TABLE(A,1)[179][178]0[167]2940
2930 ASSETS[178]ASSETS[170](TABLE(A,1)[172]TABLE(A,3))
2940 [130]A
2950 [153][163]7)"TOTAL CASH:";[163]27);"$";CASH:[153][163]7)"ASSETS PAPER VALUE:";
2955 [153][163]27);"$";ASSETS:[153][163]27)"---------"
2960 [153]"TOTAL WORTH:";[163]27);"$";CASH[170]ASSETS
2970 [153][163]7)"SUBRTRACT":[153][163]7)"START.CAPITAL:";[163]27);"$10000":[153][163]27);
2975 [153]"---------"
2980 [153][163]7);"GROSS INCOME:";[163]27);"$";(CASH[170]ASSETS)[171]10000
2985 [153][163]7);"LESS ASSETS:";[163]27);"$";ASSETS
2990 [153][163]27)"---------":[153][163]7);"NET RECOGNIZED":[153][163]7)"INCOME";CASH[171]10000
3000 [153]:INCOME[178]CASH[171]10000:PERCENT[178][181]((INCOME[173]10000)[172]10000)[173]10
3010 [153][163]5)"YEAR'S RESULTS:":[153]"THE YEARS TRANSACTIONS NETTED":[153][163]5);
3020 [139]PERCENT[177][178]0[167]3040
3030 [153]"A ";PERCENT;"% DECREASE ";:[137]3050
3040 [153]"A ";PERCENT;"% INCREASE ";
3050 [153]"IN CASH , WITH A"
3060 PERCENT[178][181]((((ASSETS[170]CASH)[171]10000)[173]10000)[172]1000)[173]10
3070 [139]PERCENT[177][178]0[167]3090
3080 [153][163]5);[182](PERCENT);"% DECREASE ";:[137]3100
3090 [153][163]5);PERCENT;"% INCREASE ";
3100 [153]"IN NET WORTH"
3110 [128]
4000 [143] ERASE SUBROUTINE
4010 [153]"";
4020 [129]X[178]1[164]13
4030 [153][163]24);" "
4040 [130]:[142]
4500 [143] ERASE SUBROUTINE
4510 [153]"";
4520 [129]X[178]1[164]13
4530 [153][163]17);" "
4540 [130]:[142]